<div class="admin-content">

  <div class="am-cf am-padding">
    <div class="am-fl am-cf"> <strong class="am-text-primary am-text-lg">收信箱</strong>
      /
      <small>News</small>
    </div>
  </div>

  <div class="am-g">
    <div class="am-u-sm-12">
        <table class="am-table am-table-striped am-table-hover table-main">
          <thead>
            <tr>
              <th class="table-id">ID</th>
              <th class="table-title">类型</th>
              <th class="table-type">内容</th>
              <th class="table-author">时间</th>
              <th class="table-set">操作</th>
            </tr>
          </thead>
          <tbody>
            <?php foreach($list as $k => $v):?>

            <tr style="<?=$v['status'] == 1 ? 'color:blue' : ''?>">
              <td><?=$v['id']?></td>
              <td><?=$v['type_name']?></td>
              <td><?=$v['content']?></td>
              <td><?=date('Y年m月d日 H:i:s',$v['create_time'])?></td>
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <?php if($v['status'] == 1):?>
                    <button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="set_status('<?=$v['id']?>')">
                      <span class="am-icon-pencil-square-o"></span>
                      已读
                    </button>
                    <?php endif;?>
                    <button class="am-btn am-btn-default am-btn-xs am-text-danger" onclick="del_news('<?=$v['id']?>')">
                      <span class="am-icon-trash-o"></span>
                      删除
                    </button>
                  </div>
                </div>
              </td>
            </tr>
            <?php endforeach;?>
          </tbody>
        </table>
        <div id="msg">
        </div>
        <div class="am-cf">
          共 <?=$rows?> 条记录
          <div class="am-fr">
            <ul class="am-pagination"><?=$page?></ul>
          </div>
        </div>
        <hr />
        <p>注：.....</p>
    </div>

  </div>
</div>

<script type="text/javascript">
  function set_status(nid){
    $.get("<?=site_url('news/set_status')?>",{id:nid},function(res){

      if(res == 1){
        location.reload();
      }else{
        var data = '<div class="am-alert am-alert-danger" onclick="msg_close()"><span class="am-icon-close am-icon-sm">  '+res+'</span><br/></div>';
        set_msg(data);
      }
    })
  }

  function del_news(nid){
    $.post("<?=site_url('news/del_news')?>",{nid:nid},function(res){

      if(res == 1){
        location.reload();
      }else{
        var data = '<div class="am-alert am-alert-danger" onclick="msg_close()"><span class="am-icon-close am-icon-sm">  '+res+'</span><br/></div>';
        set_msg(data);
      }
    })
  }
</script>